package com.cyy.partner.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyy.partner.mapper.UserMapper;
import com.cyy.partner.pojo.User;
import com.cyy.partner.service.UserService;
import com.cyy.partner.utils.Md5Util;
import com.cyy.partner.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @Author: cyy
 * @Date: 2024/4/11
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public void resetPassword(String newPassword) {
        HashMap<String, Object> claims = ThreadLocalUtil.get();
        Long id = (Long) claims.get("id");
        User user = getById(id);
        user.setPassword(Md5Util.getMD5String(newPassword));
        userMapper.updateById(user);
    }
}
